Transaction log layout for efficient reclamation and recovery

ABSTRACT

A layout of a transaction log enables efficient logging of metadata into entries of the log, as well as efficient reclamation and recovery of the log entries by a volume layer of a storage input/output (I/O) stack executing on one or more nodes of a cluster. The transaction log is illustratively a two stage, append-only logging structure, wherein the first level is non-volatile random access memory (NVRAM) embodied as a NVlog and the second stage is disk, e.g., solid state drive (SSD). During crash recovery, the log entries are examined for consistency and scanned to identify those entries that have completed and those that are active, which require replay. The log entries are walked from oldest to newest (using sequence numbers) searching for the highest sequence number. Partially complete log entries (e.g., log entries in-progress when a crash occurs) may be discarded for failing a checksum (e.g., a CRC error). Old value/new value logs may be used to implement roll-forward or roll-back semantics to replay the log entries and fix any on-disk data structures, first from NVRAM and then from on-disk logs.

RELATED APPLICATIONS

The present application is a divisional of U.S. patent application Ser.No. 14/872,793, entitled “Transaction Log Layout for EfficientReclamation and Recovery”, filed by Srinath Krishnamachari et al. onOct. 1, 2015, the contents of which are hereby incorporated byreference.

BACKGROUND

Technical Field

The present disclosure relates to storage systems and, morespecifically, to a layout of a transaction log that enables efficientlogging of metadata into entries of the log in a storage system, as wellas efficient reclamation and recovery of the log entries.

Background Information

A plurality of storage systems may be interconnected as a cluster andconfigured to provide storage service relating to the organization ofstorage containers stored on storage devices, such as disks, coupled tothe systems. The storage system cluster may be further configured tooperate according to a client/server model of information delivery tothereby allow one or more clients (hosts) to access the storagecontainers. The disks may be embodied as solid-state drives (SSDs), suchas flash storage devices, whereas the storage containers may be embodiedas files or logical units (LUNs). Each storage container may beimplemented as a set of data structures, such as data blocks that storedata for the storage container and metadata blocks that describe thedata of the storage container. For example, the metadata may describe,e.g., identify, locations of the data throughout the cluster.

The metadata may be organized and processed as one or more datastructures, wherein processing of the metadata involves execution ofoperations that modify the data structures. Modifications or changes tothe metadata of the data structures typically require access toresources of the storage system, such as central processing units (CPUs)and logs that store the metadata. As such, it is desirable that themodifications to the metadata be processed efficiently in the logs. Inaddition, it is desirable that the metadata be quickly re-playable, soas to support fast and efficient recovery of the storage service.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and further advantages of the embodiments herein may be betterunderstood by referring to the following description in conjunction withthe accompanying drawings in which like reference numerals indicateidentically or functionally similar elements, of which:

FIG. 1 is a block diagram of a plurality of nodes interconnected as acluster;

FIG. 2 is a block diagram of a node;

FIG. 3 is a block diagram of a storage input/output (I/O) stack of thenode;

FIG. 4 illustrates a write path of the storage I/O stack;

FIG. 5 illustrates a read path of the storage I/O stack;

FIG. 6 is a block diagram of various volume metadata entries;

FIG. 7 is a block diagram of a dense tree metadata structure;

FIG. 8 is a block diagram of a top level of the dense tree metadatastructure;

FIG. 9 illustrates mapping between levels of the dense tree metadatastructure;

FIG. 10 illustrates a workflow for inserting a volume metadata entryinto the dense tree metadata structure in accordance with a writerequest;

FIG. 11 illustrates merging between levels of the dense tree metadatastructure;

FIG. 12 illustrates batch updating between levels of the dense treemetadata structure;

FIG. 13 is an example simplified procedure for merging between levels ofthe dense tree metadata structure;

FIG. 14 illustrates volume logging of the dense tree metadata structure;

FIG. 15 illustrates logging in the volume layer of the storage I/Ostack; and

FIG. 16 is a block diagram of the volume layer log format of the storageI/O stack.

OVERVIEW

The embodiments herein are directed to a layout of a transaction logthat enables efficient logging of metadata into entries of the log, aswell as efficient reclamation and recovery of the log entries by avolume layer of a storage input/output (I/O) stack executing on one ormore nodes of a cluster. The transaction log is illustratively a twostage, append-only logging structure, wherein the first stage isnon-volatile random access memory (NVRAM) embodied as a NVlog and thesecond stage is disk, e.g., solid state drive (SSD). When the NVlog isfull, the metadata may be flushed (written) to SSD as one or moreextents. As described herein, the layout of the logging structurefacilitates steady-state logging of metadata managed by the volume layerand facilitates crash recovery. Steady-state logging of metadata intothe log entries occurs while the storage I/O stack of a node activelyprocesses I/O requests, while crash recovery of the log entries occursafter an unexpected shutdown of the node.

In an embodiment, the metadata managed by the volume layer, i.e., thevolume metadata, is illustratively embodied as mappings from addresses,i.e., logical block addresses (LBAs), of a logical unit (LUN) accessibleby a host to durable extent keys. The volume layer organizes the volumemetadata as one or more multi-level dense tree structures, wherein eachlevel of the dense tree includes volume metadata entries for storing thevolume metadata mappings. Operations on the volume metadata managed bythe volume layer manifest as modifications or changes to metadataentries of various data structures, including the NVLog and dense treestructure, at offset ranges of the regions. Moreover, the operations(i.e., offset range operations) directed to the regions areillustratively processed by threads of execution, i.e., uniprocessor(UP) services, on central processing units (CPUs) of the nodes.

Illustratively, the NVRAM is organized as a plurality of circular logs,e.g., implemented as a plurality of NVlog buckets, each having one ormore log entries appearing virtually as a continuous log. Further, eachNVlog bucket may be associated with a different UP service to facilitatelockless concurrent operations to the respective bucket thereby, e.g.,rendering direct memory access (DMA) operations “lockless.” The volumelayer arranges the log entries for each bucket into groups oftransactions organized by indivisible classes of operation, such as adense tree merge operation, a delete operation, an insert operation, anda recovery operation. Each class of operation is associated with afinite state machine (FSM) to process the transactions for that classand ensure atomicity for each processed transaction. Further, each classof operation may require a different amount of NVRAM resources (i.e.,log space) such that concurrent operation of certain mixes of classoperations may exhaust available NVRAM resources. Accordingly, quotapools are employed to provide logical pools of NVRAM log space,allocated to an FSM, so as to process the transactions for a given classof operations. When started, an FSM may be allocated a quota pool ofsufficient size (i.e., an expected amount of NVRAM) to support the logentries for the class of operation associated with that FSM. If the poolis not available, the FSM is queued, e.g., to avoid deadlock, until sucha pool (or sufficient amount of resource) is available.

In an embodiment, a physical layout or format is provided for the logentries that includes, inter alia, sequence numbers and error correctioncodes (e.g., CRCs), as well as descriptions of the log entries thatinclude token identifiers (IDs) for identifying the FSMs associated witheach entry. As log entries are processed by the FSMs, a high watermark(i.e., threshold) for the quota pools is used to terminate (e.g.,forcefully close) long running FSMs that prevent reclamation of logspace (i.e., log entries). In-memory shadow data structures are alsoemployed to manage outstanding token IDs (FSMs), as well as to managelog space reclamation by, e.g., queuing those log entries that have notyet been reclaimed.

For crash recovery, the volume layer performs a DMA read operation toload the

NVlog buckets into main memory of the node. For each bucket, headers andfooters of the log entries are examined for consistency, and the logentries are scanned to recover token IDs and identify those entries thatare active. The log entries are then walked from oldest to newest (usingsequence numbers) searching for the highest sequence number. Any logentries (operations) associated with FSMs that have completed arediscarded, leaving the set of log entries (and associated FSMs) that areactive and, thus, require replay. Partially complete log entries (e.g.,log entries in-progress when a crash occurs) may be discarded forfailing a checksum (e.g., a CRC error). Old value/new value (OV/NV) logsmay be used to implement roll-forward or roll-back semantics to replaythe log entries and fix any on-disk data structures. Specifically, theOV/NV logs are used to copy old content of volume metadata or newcontent of volume metadata as appropriate, first from NVRAM and thenfrom on-disk logs. Based on the context of a FSM that crashed, an extentmay be patched-up (repaired) using either the old copy or new copy ofvolume metadata.

DESCRIPTION

Storage Cluster

FIG. 1 is a block diagram of a plurality of nodes 200 interconnected asa cluster 100 and configured to provide storage service relating to theorganization of information on storage devices. The nodes 200 may beinterconnected by a cluster interconnect fabric 110 and includefunctional components that cooperate to provide a distributed storagearchitecture of the cluster 100, which may be deployed in a storage areanetwork (SAN). As described herein, the components of each node 200include hardware and software functionality that enable the node toconnect to one or more hosts 120 over a computer network 130, as well asto one or more storage arrays 150 of storage devices over a storageinterconnect 140, to thereby render the storage service in accordancewith the distributed storage architecture.

Each host 120 may be embodied as a general-purpose computer configuredto interact with any node 200 in accordance with a client/server modelof information delivery. That is, the client (host) may request theservices of the node, and the node may return the results of theservices requested by the host, by exchanging packets over the network130. The host may issue packets including file-based access protocols,such as the Network File System (NFS) protocol over the TransmissionControl Protocol/Internet Protocol (TCP/IP), when accessing informationon the node in the form of storage containers such as files anddirectories. However, in an embodiment, the host 120 illustrativelyissues packets including block-based access protocols, such as the SmallComputer Systems Interface (SCSI) protocol encapsulated over TCP (iSCSI)and SCSI encapsulated over FC (FCP), when accessing information in theform of storage containers such as logical units (LUNs). Notably, any ofthe nodes 200 may service a request directed to a storage container onthe cluster 100.

FIG. 2 is a block diagram of a node 200 that is illustratively embodiedas a storage system having one or more central processing units (CPUs)210 coupled to a memory 220 via a memory bus 215. The CPU (i.e., CPUsocket) 210 is also coupled to a network adapter 230, one or morestorage controllers 240, a cluster interconnect interface 250 and anon-volatile random access memory (NVRAM 280) via a system interconnect270. The network adapter 230 may include one or more ports adapted tocouple the node 200 to the host(s) 120 over computer network 130, whichmay include point-to-point links, wide area networks, virtual privatenetworks implemented over a public network (Internet) or a local areanetwork. The network adapter 230 thus includes the mechanical,electrical and signaling circuitry needed to connect the node to thenetwork 130, which illustratively embodies an Ethernet or Fibre Channel(FC) network.

The memory 220 may include memory locations that are addressable by theCPU 210 for storing software programs and data structures associatedwith the embodiments described herein. The CPU socket 210 may, in turn,include processing elements and/or logic circuitry configured to executethe software programs, such as a storage input/output (I/O) stack 300,and manipulate the data structures. The processing elements and/or logiccircuitry may include processor (CPU) cores 215 a-n and a shared cache(e.g., a last level cache) 218. Illustratively, the storage I/O stack300 may be implemented as a set of user mode processes that may bedecomposed into a plurality of threads. An operating system kernel 224,portions of which are typically resident in memory 220 (in-core) andexecuted by the processing elements (i.e., CPU 210), functionallyorganizes the node by, inter alia, invoking operations in support of thestorage service implemented by the node and, in particular, the storageI/O stack 300. A suitable operating system kernel 224 may include ageneral-purpose operating system, such as the UNIX® series or MicrosoftWindows® series of operating systems, or an operating system withconfigurable functionality such as microkernels and embedded kernels.However, in an embodiment described herein, the operating system kernelis illustratively the Linux® operating system. It will be apparent tothose skilled in the art that other processing and memory means,including various computer readable media, may be used to store andexecute program instructions pertaining to the embodiments herein.

Each storage controller 240 cooperates with the storage I/O stack 300executing on the node 200 to access information requested by the host120. The information is preferably stored on storage devices such assolid state drives (SSDs) 260, illustratively embodied as flash storagedevices, of storage array 150. In an embodiment, the flash storagedevices may be based on NAND flash components, e.g., single-layer-cell(SLC) flash, multi-layer-cell (MLC) flash or triple-layer-cell (TLC)flash, although it will be understood to those skilled in the art thatother block-oriented, non-volatile, solid-state electronic devices(e.g., drives based on storage class memory components) may beadvantageously used with the embodiments described herein. Accordingly,the storage devices may or may not be block-oriented (i.e., accessed asblocks). The storage controller 240 includes one or more ports havingI/O interface circuitry that couples to the SSDs 260 over the storageinterconnect 140, illustratively embodied as a serial attached SCSI(SAS) topology. Alternatively, other point-to-point I/O interconnectarrangements such as a conventional serial ATA (SATA) topology or a PCItopology, may be used. The system interconnect 270 may also couple thenode 200 to a local service storage device 248, such as an SSD,configured to locally store cluster-related configuration information,e.g., as cluster database (DB) 244, which may be replicated to the othernodes 200 in the cluster 100.

The cluster interconnect interface 250 may include one or more portsadapted to couple the node 200 to the other node(s) of the cluster 100.In an embodiment, Ethernet may be used as the clustering protocol andinterconnect fabric media, although it will be apparent to those skilledin the art that other types of protocols and interconnects, such asInfiniband, may be utilized within the embodiments described herein. TheNVRAM 280 may include a back-up battery or other built-in last-stateretention capability (e.g., non-volatile semiconductor memory such asstorage class memory) that is capable of maintaining data in light of afailure to the node and cluster environment. Illustratively, a portionof the NVRAM 280 may be configured as one or more non-volatile logs(NVLogs 285) configured to temporarily record (“log”) I/O requests, suchas write requests, received from the host 120.

Storage I/O Stack

FIG. 3 is a block diagram of the storage I/O stack 300 that may beadvantageously used with one or more embodiments described herein. Thestorage I/O stack 300 includes a plurality of software modules or layersthat cooperate with other functional components of the nodes 200 toprovide the distributed storage architecture of the cluster 100. In anembodiment, the distributed storage architecture presents an abstractionof a single storage container, i.e., all of the storage arrays 150 ofthe nodes 200 for the entire cluster 100 organized as one large pool ofstorage. In other words, the architecture consolidates storage, i.e.,the SSDs 260 of the arrays 150, throughout the cluster (retrievable viacluster-wide keys) to enable storage of the LUNs. Both storage capacityand performance may then be subsequently scaled by adding nodes 200 tothe cluster 100.

Illustratively, the storage I/O stack 300 includes an administrationlayer 310, a protocol layer 320, a persistence layer 330, a volume layer340, an extent store layer 350, a Redundant Array of Independent Disks(RAID) layer 360, a storage layer 365 and a NVRAM (storing NVLogs)“layer” interconnected with a messaging kernel 370. The messaging kernel370 may provide a message-based (or event-based) scheduling model (e.g.,asynchronous scheduling) that employs messages as fundamental units ofwork exchanged (i.e., passed) among the layers. Suitable message-passingmechanisms provided by the messaging kernel to transfer informationbetween the layers of the storage I/O stack 300 may include, e.g., forintra-node communication: i) messages that execute on a pool of threads,ii) messages that execute on a single thread progressing as an operationthrough the storage I/O stack, iii) messages using an Inter ProcessCommunication (IPC) mechanism and, e.g., for inter-node communication:messages using a Remote Procedure Call (RPC) mechanism in accordancewith a function shipping implementation. Alternatively, the I/O stackmay be implemented using a thread-based or stack-based execution model.In one or more embodiments, the messaging kernel 370 allocatesprocessing resources from the operating system kernel 224 to execute themessages. Each storage I/O stack layer may be implemented as one or moreinstances (i.e., processes) executing one or more threads (e.g., inkernel or user space) that process the messages passed between thelayers such that the messages provide synchronization for blocking andnon-blocking operation of the layers.

In an embodiment, the protocol layer 320 may communicate with the host120 over the network 130 by exchanging discrete frames or packetsconfigured as I/O requests according to pre-defined protocols, such asiSCSI and FCP. An I/O request, e.g., a read or write request, may bedirected to a LUN and may include I/O parameters such as, inter alia, aLUN identifier (ID), a logical block address (LBA) of the LUN, a length(i.e., amount of data) and, in the case of a write request, write data.The protocol layer 320 receives the I/O request and forwards it to thepersistence layer 330, which records the request into a persistentwrite-back cache 380, illustratively embodied as a log whose contentscan be replaced randomly, e.g., under some random access replacementpolicy rather than only in serial fashion, and returns anacknowledgement to the host 120 via the protocol layer 320. In anembodiment only I/O requests that modify the LUN, e.g., write requests,are logged. Notably, the I/O request may be logged at the node receivingthe I/O request, or in an alternative embodiment in accordance with thefunction shipping implementation, the I/O request may be logged atanother node.

Illustratively, dedicated logs may be maintained by the various layersof the storage I/O stack 300. For example, a dedicated log 335 may bemaintained by the persistence layer 330 to record the I/O parameters ofan I/O request as equivalent internal, i.e., storage I/O stack,parameters, e.g., volume ID, offset, and length. In the case of a writerequest, the persistence layer 330 may also cooperate with the NVRAM 280to implement the write-back cache 380 configured to store the write dataassociated with the write request. In an embodiment, the write-backcache 380 may be structured as a log. Notably, the write data for thewrite request may be physically stored in the cache 380 such that thelog 335 contains the reference to the associated write data. It will beunderstood to persons skilled in the art the other variations of datastructures may be used to store or maintain the write data in NVRAMincluding data structures with no logs. In an embodiment, a copy of thewrite-back cache may also be maintained in the memory 220 to facilitatedirect memory access to the storage controllers. In other embodiments,caching may be performed at the host 120 or at a receiving node inaccordance with a protocol that maintains coherency between the datastored at the cache and the cluster.

In an embodiment, the administration layer 310 may apportion the LUNinto multiple volumes, each of which may be partitioned into multipleregions (e.g., allotted as disjoint block address ranges), with eachregion having one or more segments stored as multiple stripes on thearray 150. A plurality of volumes distributed among the nodes 200 maythus service a single LUN, i.e., each volume within the LUN services adifferent LBA range (i.e., offset range) or set of ranges within theLUN. Accordingly, the protocol layer 320 may implement a volume mappingtechnique to identify a volume to which the I/O request is directed(i.e., the volume servicing the offset range indicated by the parametersof the I/O request). Illustratively, the cluster database 244 may beconfigured to maintain one or more associations (e.g., key-value pairs)for each of the multiple volumes, e.g., an association between the LUNID and a volume, as well as an association between the volume and a nodeID for a node managing the volume. The administration layer 310 may alsocooperate with the database 244 to create (or delete) one or morevolumes associated with the LUN (e.g., creating a volume ID/LUNkey-value pair in the database 244). Using the LUN ID and LBA (or LBArange), the volume mapping technique may provide a volume ID (e.g.,using appropriate associations in the cluster database 244) thatidentifies the volume and node servicing the volume destined for therequest, as well as translate the LBA (or LBA range) into an offset andlength within the volume. Specifically, the volume ID is used todetermine a volume layer instance that manages volume metadataassociated with the LBA or LBA range. As noted, the protocol layer 320may pass the I/O request (i.e., volume ID, offset and length) to thepersistence layer 330, which may use the function shipping (e.g.,inter-node) implementation to forward the I/O request to the appropriatevolume layer instance executing on a node in the cluster based on thevolume ID.

In an embodiment, the volume layer 340 may manage the volume metadataby, e.g., maintaining states of host-visible containers, such as rangesof LUNs, and performing data management functions, such as creation ofsnapshots and clones, for the LUNs in cooperation with theadministration layer 310. The volume metadata is illustratively embodiedas in-core mappings from LUN addresses (i.e., LBAs) to durable extentkeys, which are unique cluster-wide IDs associated with SSD storagelocations for extents within an extent key space of the cluster-widestorage container. That is, an extent key may be used to retrieve thedata of the extent at an SSD storage location associated with the extentkey. Alternatively, there may be multiple storage containers in thecluster wherein each container has its own extent key space, e.g., wherethe administration layer 310 provides distribution of extents among thestorage containers. An extent is a variable length block of data thatprovides a unit of storage on the SSDs and that need not be aligned onany specific boundary, i.e., it may be byte aligned. Accordingly, anextent may be an aggregation of write data from a plurality of writerequests to maintain such alignment. Illustratively, the volume layer340 may record the forwarded request (e.g., information or parameterscharacterizing the request), as well as changes to the volume metadata,in dedicated log 345 maintained by the volume layer 340. Subsequently,the contents of the volume layer log 345 may be written to the storagearray 150 in accordance with a checkpoint (e.g., synchronization)operation that stores in-core metadata on the array 150. That is, thecheckpoint operation (checkpoint) ensures that a consistent state ofmetadata, as processed in-core, is committed to (i.e., stored on) thestorage array 150; whereas the retirement of log entries ensures thatthe entries accumulated in the volume layer log 345 synchronize with themetadata checkpoints committed to the storage array 150 by, e.g.,retiring those accumulated log entries that are prior to the checkpoint.In one or more embodiments, the checkpoint and retirement of log entriesmay be data driven, periodic or both.

In an embodiment, the extent store layer 350 is responsible for storingextents prior to storage on the SSDs 260 (i.e., on the storage array150) and for providing the extent keys to the volume layer 340 (e.g., inresponse to a forwarded write request). The extent store layer 350 isalso responsible for retrieving data (e.g., an existing extent) using anextent key (e.g., in response to a forwarded read request). The extentstore layer 350 may be responsible for performing de-duplication andcompression on the extents prior to storage. The extent store layer 350may maintain in-core mappings (e.g., embodied as hash tables) of extentkeys to SSD storage locations (e.g., offset on an SSD 260 of array 150).The extent store layer 350 may also maintain a dedicated log 355 ofentries that accumulate requested “put” and “delete” operations (i.e.,write requests and delete requests for extents issued from other layersto the extent store layer 350), where these operations change thein-core mappings (i.e., hash table entries). Subsequently, the in-coremappings and contents of the extent store layer log 355 may be writtento the storage array 150 in accordance with a “fuzzy” checkpoint 390(i.e., checkpoint with incremental changes recorded in one or more logfiles) in which selected in-core mappings, less than the total, arecommitted to the array 150 at various intervals (e.g., driven by anamount of change to the in-core mappings, size thresholds of log 355, orperiodically). Notably, the accumulated entries in log 355 may beretired once all in-core mappings have been committed to include thechanges recorded in those entries prior to the first interval.

In an embodiment, the RAID layer 360 may organize the SSDs 260 withinthe storage array 150 as one or more RAID groups (e.g., sets of SSDs)that enhance the reliability and integrity of extent storage on thearray by writing data “stripes” having redundant information, i.e.,appropriate parity information with respect to the striped data, acrossa given number of SSDs 260 of each RAID group. The RAID layer 360 mayalso store a number of stripes (e.g., stripes of sufficient depth) atonce, e.g., in accordance with a plurality of contiguous writeoperations, so as to reduce data relocation (i.e., internal flash blockmanagement) that may occur within the SSDs as a result of theoperations. In an embodiment, the storage layer 365 implements storageI/O drivers that may communicate directly with hardware (e.g., thestorage controllers and cluster interface) cooperating with theoperating system kernel 224, such as a Linux virtual function I/O (VFIO)driver.

Write Path

FIG. 4 illustrates an I/O (e.g., write) path 400 of the storage I/Ostack 300 for processing an I/O request, e.g., a SCSI write request 410.The write request 410 may be issued by host 120 and directed to a LUNstored on the storage array 150 of the cluster 100. Illustratively, theprotocol layer 320 receives and processes the write request by decoding420 (e.g., parsing and extracting) fields of the request, e.g., LUN ID,LBA and length (shown at 413), as well as write data 414. The protocollayer may use the results 422 from decoding 420 for a volume mappingtechnique 430 (described above) that translates the LUN ID and LBA range(i.e., equivalent offset and length) of the write request to anappropriate volume layer instance, i.e., volume ID (volume 445), in thecluster 100 that is responsible for managing volume metadata for the LBArange. In an alternative embodiment, the persistence layer 330 mayimplement the above described volume mapping technique 430. The protocollayer then passes the results 432, e.g., volume ID, offset, length (aswell as write data), to the persistence layer 330, which records therequest in the persistent layer log 335 and returns an acknowledgementto the host 120 via the protocol layer 320. The persistence layer 330may aggregate and organize write data 414 from one or more writerequests into a new extent 470 and perform a hash computation, i.e., ahash function, on the new extent to generate a hash value 472 inaccordance with an extent hashing technique 474.

The persistent layer 330 may then pass the write request with aggregatedwrite date including, e.g., the volume ID, offset and length, asparameters 434 of a message to the appropriate volume layer instance. Inan embodiment, message passing of the parameters 434 (received by thepersistent layer) may be redirected to another node via the functionshipping mechanism, e.g., RPC, for inter-node communication.Alternatively, message passing of parameters 434 may be via the IPCmechanism, e.g., message threads, for intra-node communication.

In one or more embodiments, a bucket mapping technique 476 is providedthat translates the hash value 472 to an instance of an appropriateextent store layer (e.g., extent store instance 478) that is responsiblefor storing the new extent 470. Note that the bucket mapping techniquemay be implemented in any layer of the storage I/O stack above theextent store layer. In an embodiment, for example, the bucket mappingtechnique may be implemented in the persistence layer 330, the volumelayer 340, or a layer that manages cluster-wide information, such as acluster layer (not shown). Accordingly, the persistence layer 330, thevolume layer 340, or the cluster layer may contain computer executableinstructions executed by the CPU 210 to perform operations thatimplement the bucket mapping technique 476. The persistence layer 330may then pass the hash value 472 and the new extent 470 to theappropriate volume layer instance and onto the appropriate extent storeinstance via an extent store put operation. The extent hashing technique474 may embody an approximately uniform hash function to ensure that anyrandom extent to be written may have an approximately equal chance offalling into any extent store instance 478, i.e., hash buckets aredistributed across extent store instances of the cluster 100 based onavailable resources. As a result, the bucket mapping technique 476provides load-balancing of write operations (and, by symmetry, readoperations) across nodes 200 of the cluster, while also leveling flashwear in the SSDs 260 of the cluster.

In response to the put operation, the extent store instance may processthe hash value 472 to perform an extent metadata selection technique 480that (i) selects an appropriate hash table 482 (e.g., hash table 482 a)from a set of hash tables (illustratively in-core) within the extentstore instance 478, and (ii) extracts a hash table index 484 from thehash value 472 to index into the selected hash table and lookup a tableentry having an extent key 618 identifying a storage location 490 on SSD260 for the extent. Accordingly, the extent store layer 350 containscomputer executable instructions executed by the CPU 210 to performoperations that implement the extent metadata selection technique 480described herein. If a table entry with a matching extent key is found,then the SSD location 490 mapped from the extent key 618 is used toretrieve an existing extent (not shown) from SSD. The existing extent isthen compared with the new extent 470 to determine whether their data isidentical. If the data is identical, the new extent 470 is alreadystored on SSD 260 and a de-duplication opportunity (denotedde-duplication 452) exists such that there is no need to write anothercopy of the data. Accordingly, a reference count (not shown) in thetable entry for the existing extent is incremented and the extent key618 of the existing extent is passed to the appropriate volume layerinstance for storage within an entry (denoted as volume metadata entry600) of a dense tree metadata structure (e.g., dense tree 700 a), suchthat the extent key 618 is associated an offset range 440 (e.g., offsetrange 440 a) of the volume 445.

However, if the data of the existing extent is not identical to the dataof the new extent 470, a collision occurs and a deterministic algorithmis invoked to sequentially generate as many new candidate extent keys(not shown) mapping to the same bucket as needed to either providede-duplication 452 or produce an extent key that is not already storedwithin the extent store instance. Notably, another hash table (e.g. hashtable 482 n) may be selected by a new candidate extent key in accordancewith the extent metadata selection technique 480. In the event that node-duplication opportunity exists (i.e., the extent is not alreadystored) the new extent 470 is compressed in accordance with compressiontechnique 454 and passed to the RAID layer 360, which processes the newextent 470 for storage on SSD 260 within one or more stripes 464 of RAIDgroup 466. The extent store instance may cooperate with the RAID layer360 to identify a storage segment 460 (i.e., a portion of the storagearray 150) and a location on SSD 260 within the segment 460 in which tostore the new extent 470. Illustratively, the identified storage segmentis a segment with a large contiguous free space having, e.g., location490 on SSD 260 b for storing the extent 470.

In an embodiment, the RAID layer 360 then writes the stripe 464 acrossthe RAID group 466, illustratively as one or more full stripe writes462. The RAID layer 360 may write a series of stripes 464 of sufficientdepth to reduce data relocation that may occur within the flash-basedSSDs 260 (i.e., flash block management). The extent store instance then(i) loads the SSD location 490 of the new extent 470 into the selectedhash table 482 n (i.e., as selected by the new candidate extent key),(ii) passes a new extent key (denoted as extent key 618) to theappropriate volume layer instance for storage within an entry (alsodenoted as volume metadata entry 600) of a dense tree 700 managed bythat volume layer instance, and (iii) records a change to extentmetadata of the selected hash table in the extent store layer log 355.Illustratively, the volume layer instance selects dense tree 700 aspanning an offset range 440 a of the volume 445 that encompasses theLBA range of the write request. As noted, the volume 445 (e.g., anoffset space of the volume) is partitioned into multiple regions (e.g.,allotted as disjoint offset ranges); in an embodiment, each region isrepresented by a dense tree 700. The volume layer instance then insertsthe volume metadata entry 600 into the dense tree 700 a and records achange corresponding to the volume metadata entry in the volume layerlog 345. Accordingly, the I/O (write) request is sufficiently stored onSSD 260 of the cluster.

Read Path

FIG. 5 illustrates an I/O (e.g., read) path 500 of the storage I/O stack300 for processing an I/O request, e.g., a SCSI read request 510. Theread request 510 may be issued by host 120 and received at the protocollayer 320 of a node 200 in the cluster 100. Illustratively, the protocollayer 320 processes the read request by decoding 420 (e.g., parsing andextracting) fields of the request, e.g., LUN ID, LBA, and length (shownat 513), and uses the results 522, e.g., LUN ID, offset, and length, forthe volume mapping technique 430. That is, the protocol layer 320 mayimplement the volume mapping technique 430 (described above) totranslate the LUN ID and LBA range (i.e., equivalent offset and length)of the read request to an appropriate volume layer instance, i.e.,volume ID (volume 445), in the cluster 100 that is responsible formanaging volume metadata for the LBA (i.e., offset) range. The protocollayer then passes the results 532 to the persistence layer 330, whichmay search the write cache 380 to determine whether some or all of theread request can be serviced from its cached data. If the entire requestcannot be serviced from the cached data, the persistence layer 330 maythen pass the remaining portion of the request including, e.g., thevolume ID, offset and length, as parameters 534 to the appropriatevolume layer instance in accordance with the function shipping mechanism(e.g., RPC for inter-node communication) or the IPC mechanism (e.g.,message threads, for intra-node communication).

The volume layer instance may process the read request to access a densetree metadata structure (e.g., dense tree 700a) associated with a region(e.g., offset range 440 a) of a volume 445 that encompasses therequested offset range (specified by parameters 534). The volume layerinstance may further process the read request to search for (lookup) oneor more volume metadata entries 600 of the dense tree 700 a to obtainone or more extent keys 618 associated with one or more extents 470within the requested offset range. As described further herein, eachdense tree 700 may be embodied as a multiple levels of a searchstructure with possibly overlapping offset range entries at each level.The entries, i.e., volume metadata entries 600, provide mappings fromhost-accessible LUN addresses, i.e., LBAs, to durable extent keys. Thevarious levels of the dense tree may have volume metadata entries 600for the same offset, in which case the higher level has the newer entryand is used to service the read request. A top level of the dense tree700 is illustratively resident in-core and a page cache 448 may be usedto access lower levels of the tree. If the requested range or portionthereof is not present in the top level, a metadata page associated withan index entry at the next lower tree level is accessed. The metadatapage (i.e., in the page cache 448) at the next level is then searched(e.g., a binary search) to find any overlapping entries. This process isthen iterated until one or more volume metadata entries 600 of a levelare found to ensure that the extent key(s) 618 for the entire requestedread range are found. If no metadata entries exist for the entire orportions of the requested read range, then the missing portion(s) arezero filled.

Once found, each extent key 618 is processed by the volume layer 340 to,e.g., implement the bucket mapping technique 476 that translates theextent key to an appropriate extent store instance 478 responsible forstoring the requested extent 470. Note that, in an embodiment, eachextent key 618 is substantially identical to hash value 472 associatedwith the extent 470, i.e., the hash value as calculated during the writerequest for the extent, such that the bucket mapping 476 and extentmetadata selection 480 techniques may be used for both write and readpath operations. Note also that the extent key 618 may be derived fromthe hash value 472. The volume layer 340 may then pass the extent key618 (i.e., the hash value 472 from a previous write request for theextent) to the appropriate extent store instance 478 (via an extentstore get operation), which performs an extent key-to-SSD mapping todetermine the location on SSD 260 for the extent.

In response to the get operation, the extent store instance may processthe extent key 618 (i.e., hash value 472) to perform the extent metadataselection technique 480 that (i) selects an appropriate hash table(e.g., hash table 482a) from a set of hash tables within the extentstore instance 478, and (ii) extracts a hash table index 484 from theextent key 618 (i.e., hash value 472) to index into the selected hashtable and lookup a table entry having a matching extent key 618 thatidentifies a storage location 490 on SSD 260 for the extent 470. Thatis, the SSD location 490 mapped to the extent key 618 may be used toretrieve the existing extent (denoted as extent 470) from SSD 260 (e.g.,SSD 260 b). The extent store instance then cooperates with the RAIDstorage layer 360 to access the extent on SSD 260 b and retrieve thedata contents in accordance with the read request. Illustratively, theRAID layer 360 may read the extent in accordance with an extent readoperation 468 and pass the extent 470 to the extent store instance. Theextent store instance may then decompress the extent 470 in accordancewith a decompression technique 456, although it will be understood tothose skilled in the art that decompression can be performed at anylayer of the storage I/O stack 300. The extent 470 may be stored in abuffer (not shown) in memory 220 and a reference to that buffer may bepassed back through the layers of the storage I/O stack. The persistencelayer may then load the extent into a read cache 580 (or other stagingmechanism) and may extract appropriate read data 512 from the read cache580 for the LBA range of the read request 510. Thereafter, the protocollayer 320 may create a SCSI read response 514, including the read data512, and return the read response to the host 120.

Dense Tree Volume Metadata

As noted, a host-accessible LUN may be apportioned into multiplevolumes, each of which may be partitioned into one or more regions,wherein each region is associated with a disjoint offset range, i.e., aLBA range, owned by an instance of the volume layer 340 executing on anode 200. For example, assuming a maximum volume size of 64 terabytes(TB) and a region size of 16 gigabytes (GB), a volume may have up to4096 regions (i.e., 16 GB×4096=64 TB). In an embodiment, region 1 may beassociated with an offset range of, e.g., 0-16 GB, region 2 may beassociated with an offset range of 16 GB-32 GB, and so forth. Ownershipof a region denotes that the volume layer instance manages metadata,i.e., volume metadata, for the region, such that I/O requests destinedto an offset range within the region are directed to the owning volumelayer instance. Thus, each volume layer instance manages volume metadatafor, and handles I/O requests to, one or more regions. A basis formetadata scale-out in the distributed storage architecture of thecluster 100 includes partitioning of a volume into regions anddistributing of region ownership across volume layer instances of thecluster.

Volume metadata, as well as data storage, in the distributed storagearchitecture is illustratively extent based. The volume metadata of aregion that is managed by the volume layer instance is illustrativelyembodied as in memory (in-core) and on SSD (on-flash) volume metadataconfigured to provide mappings from host-accessible LUN addresses, i.e.,LBAs, of the region to durable extent keys. In other words, the volumemetadata maps LBA (i.e., offset) ranges of the LUN to data of the LUN(via extent keys) within the respective LBA range. In an embodiment, thevolume layer organizes the volume metadata (embodied as volume metadataentries 600) as a data structure, i.e., a dense tree metadata structure(dense tree 700), which maps an offset range within the region to one ormore extent keys. That is, LUN data (user data) stored as extents is(accessible via extent keys) is associated with LUN offset (i.e., LBA)ranges represented as volume metadata (also stored as extents).Accordingly, the volume layer 340 contains computer executableinstructions executed by the CPU 210 to perform operations that organizeand manage the volume metadata entries of the dense tree metadatastructure described herein.

FIG. 6 is a block diagram of various volume metadata entries 600 of thedense tree metadata structure. Each volume metadata entry 600 of thedense tree 700 may be a descriptor that embodies one of a plurality oftypes, including a data entry (D) 610, an index entry (I) 620, and ahole entry (H) 630. The data entry (D) 610 is configured to map (offset,length) to an extent key for an extent (user data) and includes thefollowing content: type 612, offset 614, length 616 and extent key 618.The index entry (I) 620 is configured to map (offset, length) to a pagekey (e.g., an extent key) of a metadata page (stored as an extent),i.e., a page containing one or more volume metadata entries, at a nextlower level of the dense tree; accordingly, the index entry 620 includesthe following content: type 622, offset 624, length 626 and page key628. Illustratively, the index entry 620 manifests as a pointer from ahigher level to a lower level, i.e., the index entry 620 essentiallyserves as linkage between the different levels of the dense tree. Thehole entry (H) 630 represents absent data as a result of a hole punchingoperation at (offset, length) and includes the following content: type632, offset 634, and length 636.

In an embodiment, the volume metadata entry types are of a fixed size(e.g., 12 bytes including a type field of 1 byte, an offset of 4 bytes,a length of 1 byte, and a key of 6 bytes) to facilitate search of thedense tree metadata structure as well as storage on metadata pages.Thus, some types may have unused portions, e.g., the hole entry 630includes less information than the data entry 610 and so may have one ormore unused bytes. In an alternative embodiment, the entries may bevariable in size to avoid unused bytes. Advantageously, the volumemetadata entries may be sized for in-core space efficiency (as well asalignment on metadata pages), which improves both read and writeamplification for operations. For example, the length field (616, 626,636) of the various volume metadata entry types may represent a unit ofsector size, such as 512 bytes or 520 bytes, such that a 1 byte lengthmay represent a range of 255×512 bytes=128K bytes.

FIG. 7 is a block diagram of the dense tree metadata structure that maybe advantageously used with one or more embodiments described herein.The dense tree metadata structure 700 is configured to provide mappingsof logical offsets within a LUN (or volume) to extent keys managed byone or more extent store instances. Illustratively, the dense treemetadata structure is organized as a multi-level dense tree 700, where atop level 800 represents recent volume metadata changes and subsequentdescending levels represent older changes. Specifically, a higher levelof the dense tree 700 is updated first and, when that level fills, anadjacent lower level is updated, e.g., via a merge operation. A latestversion of the changes may be searched starting at the top level of thedense tree and working down to the descending levels. Each level of thedense tree 700 includes fixed size records or entries, i.e., volumemetadata entries 600, for storing the volume metadata. A volume metadataprocess 710 illustratively maintains the top level 800 of the dense treein memory (in-core) as a balanced tree that enables indexing by offsets.The volume metadata process 710 also maintains a fixed sized (e.g., 4KB) in-core buffer as a staging area (i.e., an in-core staging buffer715) for volume metadata entries 600 inserted into the balanced tree(i.e., top level 800). Each level of the dense tree is furthermaintained on-flash as a packed array of volume metadata entries,wherein the entries are stored as extents illustratively organized asfixed sized (e.g., 4 KB) metadata pages 720. Notably, the staging buffer715 is de-staged to SSD upon a trigger, e.g., the staging buffer isfull. Each metadata page 720 has a unique identifier (ID), whichguarantees that no two metadata pages can have the same content.Illustratively, metadata may not be de-duplicated by the extent storelayer 350.

In an embodiment, the multi-level dense tree 700 includes three (3)levels, although it will be apparent to those skilled in the art thatadditional levels N of the dense tree may be included depending onparameters (e.g., size) of the dense tree configuration. Illustratively,the top level 800 of the tree is maintained in-core as level 0 and thelower levels are maintained on-flash as levels 1 and 2. In addition,copies of the volume metadata entries 600 stored in staging buffer 715may also be maintained on-flash as, e.g., a level 0 linked list. A leaflevel, e.g., level 2, of the dense tree contains data entries 610,whereas a non-leaf level, e.g., level 0 or 1, may contain both dataentries 610 and index entries 620. Each index entry (I) 620 at level Nof the tree is configured to point to (reference) a metadata page 720 atlevel N+1 of the tree. Each level of the dense tree 600 also includes aheader (e.g., level 0 header 730, level 1 header 740 and level 2 header750) that contains per level information, such as reference countsassociated with the extents. Each upper level header contains a headerkey (an extent key for the header, e.g., header key 732 of level 0header 730) to a corresponding lower level header. A region key 762 to aroot, e.g., level 0 header 730 (and top level 800), of the dense tree700 is illustratively stored on-flash and maintained in a volume rootextent, e.g., a volume superblock 760. Notably, the volume superblock760 contains region keys to the roots of the dense tree metadatastructures for all regions in a volume.

FIG. 8 is a block diagram of the top level 800 of the dense treemetadata structure. As noted, the top level (level 0) of the dense tree700 is maintained in-core as a balanced tree, which is illustrativelyembodied as a B+ tree data structure. However, it will be apparent tothose skilled in the art that other data structures, such as AVL trees,Red-Black trees, and heaps (partially sorted trees), may beadvantageously used with the embodiments described herein. The B+ tree(top level 800) includes a root node 810, one or more internal nodes 820and a plurality of leaf nodes (leaves) 830. The volume metadata storedon the tree is preferably organized in a manner that is efficient bothto search, in order to service read requests and to traverse (walk) inascending order of offset to accomplish merges to lower levels of thetree. The B+ tree has certain properties that satisfy theserequirements, including storage of all data (i.e., volume metadataentries 600) in leaves 830 and storage of the leaves as sequentiallyaccessible, e.g., as one or more linked lists. Both of these propertiesmake sequential read requests for write data (i.e., extents) and readoperations for dense tree merge more efficient. Also, since it has amuch higher fan-out than a binary search tree, the illustrative B+ treeresults in more efficient lookup operations. As an optimization, theleaves 830 of the B+ tree may be stored in a page cache 448, makingaccess of data more efficient than other trees. In addition, resolutionof overlapping offset entries in the B+ tree optimizes read requests ofextents. Accordingly, the larger the fraction of the B+ tree (i.e.,volume metadata) maintained in-core, the less loading (reading) ofmetadata from SSD is required so as to reduce read amplification.

FIG. 9 illustrates mappings 900 between levels of the dense treemetadata structure. Each level of the dense tree 700 includes one ormore metadata pages 720, each of which contains multiple volume metadataentries 600. As noted, each volume metadata entry 600 has a fixed size,e.g., 12 bytes, such that a predetermined number of entries may bepacked into each metadata page 720. The data entry (D) 610 is a map of(offset, length) to an address of (user) data which is retrievable usingan extent key 618 (i.e., from an extent store instance). The (offset,length) illustratively specifies an offset range of a LUN. The indexentry (I) 620 is a map of (offset, length) to a page key 628 of ametadata page 720 at the next lower level. Illustratively, the offset inthe index entry (I) 620 is the same as the offset of the first entry inthe metadata page 720 at the next lower level. The length 626 in theindex entry 620 is illustratively the cumulative length of all entriesin the metadata page 720 at the next lower level (including gaps betweenentries).

For example, the metadata page 720 of level 1 includes an index entry“I(2K,10K)” that specifies a starting offset 2K and an ending offset 12K(i.e., 12K=2K+10K); the index entry (I) illustratively points to ametadata page 720 of level 2 covering the specified range. An aggregateview of the data entries (D) packed in the metadata page 720 of level 2covers the mapping from the smallest offset (e.g., 2K) to the largestoffset (e.g., 12K). Thus, each level of the dense tree 700 may be viewedas an overlay of an underlying level. For instance the data entry“D(0,4K)” of level 1 overlaps 2K of the underlying metadata in the pageof level 2 (i.e., the range 2K,4K).

In one or more embodiments, operations for volume metadata managed bythe volume layer 340 include insertion of volume metadata entries, suchas data entries 610, into the dense tree 700 for write requests. Asnoted, each dense tree 700 may be embodied as multiple levels of asearch structure with possibly overlapping offset range entries at eachlevel, wherein each level is a packed array of entries (e.g., sorted byoffset) and where leaf entries have an offset range (offset, length) anextent key. FIG. 10 illustrates a workflow 1000 for inserting a volumemetadata entry into the dense tree metadata structure in accordance witha write request. In an embodiment, volume metadata updates (changes) tothe dense tree 700 occur first at the top level of the tree, such that acomplete, top-level description of the changes is maintained in memory220.

Operationally, the volume metadata process 710 applies the region key762 to access the dense tree 700 (i.e., top level 800) of an appropriateregion (e.g., offset range 440 as determined from the parameters 432derived from a write request 410). Upon completion of a write request,the volume metadata process 710 creates a volume metadata entry, e.g., anew data entry 610, to record a mapping of offset/length-to-extent key(i.e., offset range-to-user data). Illustratively, the new data entry610 includes an extent key 618 (i.e., from the extent store layer 350)associated with data (i.e., extent 470) of the write request 410, aswell as offset 614 and length 616 (i.e., from the write parameters 432)and type 612 (i.e., data entry D). The volume metadata process 710 thenupdates the volume metadata by inserting (adding) the data entry D intothe level 0 staging buffer 715, as well as into the top level 800 ofdense tree 700 and the volume layer log 345, thereby signifying that thewrite request is stored on the storage array 150.

Dense Tree Volume Metadata Checkpointing

When a level of the dense tree 700 is full, volume metadata entries 600of the level are merged with the next lower level of the dense tree. Aspart of the merge, new index entries 620 are created in the level topoint to new lower level metadata pages 720, i.e., data entries from thelevel are merged (and pushed) to the lower level so that they may be“replaced” with an index reference in the level. The top level 800(i.e., level 0) of the dense tree 700 is illustratively maintainedin-core such that a merge operation to level 1 facilitates a checkpointto SSD 260. The lower levels (i.e., levels 1 and/or 2) of the dense treeare illustratively maintained on-flash and updated (e.g., merged) as abatch operation (i.e., processing the entries of one level with those ofa lower level) when the higher levels are full. The merge operationillustratively includes a sort, e.g., a 2-way merge sort operation. Aparameter of the dense tree 700 is the ratio K of the size of level N−1to the size of level N. Illustratively, the size of the array at level Nis K times larger than the size of the array at level N−1, i.e.,sizeof(level N)=K*sizeof(level N−1). After K merges from level N−1,level N becomes full (i.e., all entries from a new, fully-populatedlevel N−1 are merged with level N, iterated K times.)

FIG. 11 illustrates merging 1100 between levels, e.g., levels 0 and 1,of the dense tree metadata structure. In an embodiment, a mergeoperation is triggered when level 0 is full. When performing the mergeoperation, the dense tree metadata structure transitions to a “merge”dense tree structure (shown at 1120) that merges, while an alternate“active” dense tree structure (shown at 1150) is utilized to acceptincoming data. Accordingly, two in-core level 0 staging buffers 1130,1160 are illustratively maintained for concurrent merge and active(write) operations, respectively. In other words, an active stagingbuffer 1160 and active top level 1170 of active dense tree 1150 handlein-progress data flow (i.e., active user read and write requests), whilea merge staging buffer 1130 and merge top level 1140 of merge dense tree1120 handle consistency of the data during a merge operation. That is, a“double buffer” arrangement may be used to handle the merge of data(i.e., entries in the level 0 of the dense tree) while processing activeoperations.

During the merge operation, the merge staging buffer 1130, as well asthe top level 1140 and lower level array (e.g., merge level 1) areread-only and are not modified. The active staging buffer 1160 isconfigured to accept the incoming (user) data, i.e., the volume metadataentries received from new put operations are loaded into the activestaging buffer 1160 and added to the top level 1170 of the active densetree 1150. Illustratively, merging from level 0 to level 1 within themerge dense tree 1120 results in creation of a new active level 1 forthe active dense tree 1150, i.e., the resulting merged level 1 from themerge dense tree is inserted as a new level 1 into the active densetree. A new index entry I is computed to reference the new active level1 and the new index entry I is loaded into the active staging buffer1160 (as well as in the active top level 1170). Upon completion of themerge, the region key 762 of volume superblock 760 is updated toreference (point to) the root, e.g., active top level 1170 and activelevel 0 header (not shown), of the active dense tree 1150, therebydeleting (i.e., rendering inactive) merge level 0 and merge level 1 ofthe merge dense tree 1120. The merge staging buffer 1130 (and the toplevel 1140 of the dense tree) thus becomes an empty inactive bufferuntil the next merge. The merge data structures (i.e., the merge densetree 1120 including staging buffer 1130) may be maintained in-core and“swapped” as the active data structures at the next merge (i.e., “doublebuffered”).

FIG. 12 illustrates batch updating 1200 between lower levels, e.g.,levels 1 and 2, of the dense tree metadata structure. Illustratively, asan example, a metadata page 720 of level 1 includes four data entries Dand an index entry I referencing a metadata page 720 of level 2. Whenfull, level 1 batch updates (merges) to level 2, thus emptying the dataentries D of level 1, i.e., contiguous data entries are combined(merged) and pushed to the next lower level with a reference inserted intheir place in the level. The merge of changes of layer 1 into layer 2illustratively produces a new set of extents on SSD, i.e., new metadatapages are also stored, illustratively, in an extent store instance. Asnoted, level 2 is illustratively several times larger, e.g., K timeslarger, than level 1 so that it can support multiple merges. Each time amerge is performed, some older entries that were previously on SSD maybe deleted. Advantageously, use of the multi-level tree structure lowersthe overall frequency of volume metadata that is rewritten (and hencereduces write amplification), because old metadata may be maintained ona level while new metadata is accumulated in that level until it isfull. Further, when a plurality of upper levels become full, a multi-waymerge to a lower level may be performed (e.g., a three-way merge fromfull levels 0 and 1 to level 2).

FIG. 13 is an example simplified procedure 1300 for merging betweenlevels of the dense tree metadata structure. The procedure starts atstep 1305 and proceeds to step 1310 where incoming data received at thedense tree metadata structure is inserted into level 0, i.e., top level800, of the dense tree. Note that the incoming data is inserted into thetop level 800 as a volume metadata entry. At step 1315, a determinationis made as whether level 0, i.e., top level 800, of the dense tree isrendered full. If not, the procedure returns to step 1310; otherwise, ifthe level 0 is full, the dense tree transitions to a merge dense treestructure at step 1320. At step 1325, incoming data is loaded into anactive staging buffer of an active dense tree structure and, at step1330, the level 0 merges with level 1 of the merge dense tree structure.In response to the merge, a new active level 1 is created for the activedense tree structure at step 1335. At step 1340, an index entry iscomputed to reference the new active level 1 and, at step 1345, theindex entry is loaded into the active dense tree structure. At step1350, a region key of a volume superblock is updated to reference theactive dense tree structure and, at step 1355, the level 0 and level 1of the merge dense tree structure are rendered inactive (alternatively,deleted). The procedure then ends at step 1360.

In an embodiment, as the dense tree fills up, the volume metadata iswritten out to one or more files on SSD in a sequential format,independent of when the volume layer log 345 is de-staged and written toSSD 260, i.e., logging operations may be independent of mergeoperations. When writing volume metadata from memory 220 to SSD, directpointers to the data, e.g., in-core references to memory locations, maybe replaced with pointers to an index block in the file that referencesa location where the metadata can be found. As the files areaccumulated, they are illustratively merged together in a log-structuredmanner that continually writes the metadata sequentially to SSD. As aresult, the lower level files grow and contain volume metadata that maybe outdated because updates have occurred to the metadata, e.g., newerentries in the dense tree may overlay older entries, such as a holeentry overlaying an underlying data entry. The updates (i.e., layeredLBA ranges) are “folded” into the lower levels, thereby overwriting theoutdated metadata. The resulting dense tree structure thus includesnewly written metadata and “holes” where outdated metadata has beendeleted.

Dense Tree Volume Metadata Logging

In an embodiment, the volume layer log 345 is a two level, append-onlylogging structure, wherein the first level is NVRAM 280 (embodied asNVLogs 285) and the second level is SSD 260, e.g., stored as extents.New volume metadata entries 600 inserted into level 0 of the dense treeare also recorded in the volume layer log 345 of NVLogs 285. When thereare sufficient entries in the volume layer log 345, e.g., when the log345 is full or exceeds a threshold, the volume metadata entries areflushed (written) from log 345 (i.e., from NVRAM) to SSD 260 as one ormore extents 470. Multiple extents may be linked together with thevolume superblock 760 holding a key (i.e., an extent key) to the head ofthe list. In the case of recovery, the volume layer log 345 is read backto memory 220 to reconstruct the in-core top level 800 (i.e., level 0)of dense tree 700. Other levels may be demand paged via the page cache448, e.g., metadata pages of level 1 are loaded and read as needed.

FIG. 14 illustrates volume logging 1400 of the dense tree metadatastructure. Copies of the volume metadata entries 600 stored in level 0of the dense tree are maintained in persistent storage (SSD 260) andrecorded as volume layer log 345 in, e.g., NVLogs 285. Specifically, theentries of level 0 are stored in the in-core staging buffer 715, loggedin the append log (volume layer log 345) of NVLogs 285 and thereafterflushed to SSD 260 as a set of metadata pages 720. Copies of the level 0volume metadata are maintained in-core as the active dense tree level 0so as to service incoming read requests from memory 220. Illustratively,the in-core top level 800 (e.g., active dense tree level 0 1170) may beused as a cache (for hot metadata), whereas the volume metadata storedon the other lower levels of the dense tree are accessed less frequently(cold data) and maintained on SSD. Alternatively, the lower levels alsomay be cached using the page cache 448.

Transaction Log Layout

The embodiments herein are directed to a layout of a transaction logthat enables efficient logging of metadata into entries of the log, aswell as efficient reclamation and recovery of the log entries by thevolume layer. As previously noted, the transaction log is illustrativelya two stage, append-only logging structure of the NVlogs and SSD. Thelayout of the logging structure (e.g., the volume layer log) facilitatessteady-state logging of metadata, e.g., in response to write requests,managed by the volume layer and facilitates crash recovery. Steady-statelogging of metadata into the log entries occurs while the storage I/Ostack of a node actively processes host-initiated I/O requests (e.g.,write request 410 and read request 510), while crash recovery of the logentries occurs after an unexpected shutdown of the node. Notably, thesteady-state logging may be configured for efficient operation at theexpense of a more complex crash recovery.

FIG. 15 illustrates logging in the volume layer of the storage I/Ostack. In an embodiment, the volume layer log (i.e., NVlog 345) isorganized as a plurality of circular logs implemented as one or moreNVlog buckets 1540 a,b having log entries. Each NVlog bucket 1540 a,bmay be associated with a different thread of execution, e.g., auniprocessor (UP) service 1525 a,b executed on a CPU core 215 a,b, tofacilitate lockless concurrent operations to the respective bucket. Avolume striping technique by region (based on offset range 440 a-n) maybe employed that increases concurrency of execution directed to themetadata (e.g., volume metadata entries 600), while reducing contentionamong resources of one or more nodes 200 of the cluster. As noted,operations on the metadata managed by the volume layer manifest asmodifications or changes to metadata entries of various data structures,including the NVLogs and dense tree structures, at offset ranges 440 a-nof the regions (embodied as dense trees 700 a-n). Moreover, theoperations (i.e., offset range operations) directed to the regions areillustratively processed by the UP services 1525 a,b executing on CPUs(i.e., CPU cores 215 a,b) of the nodes.

In an embodiment, the number of NVlog buckets 1540 a,b in the volumelayer is the same as the number of UP services 1525 a,b (i.e.,one-to-one correspondence of UP services 1525 a,b to NVlog buckets 1540a,b) to thereby enable lockless operation among the NVlog buckets, i.e.,DMA write/read requests to/from the NVlog buckets in NVRAM. That is,each volume UP service has an associated NVlog bucket which renders DMAoperations lockless from the volume layer perspective. Illustratively, asingle NVRAM channel may be used, such that from the volume layer (i.e.,DMA client) perspective, each UP service has its own NVlog bucket whichavoids lock contention among the logs in NVRAM. In other words, the DMAclients (i.e., UP services) need not expressly handle contention amongthemselves, however locking may occur within an NVRAM driver shared bythose DMA clients. Such arrangement also enables a recovery mechanism tobe lockless; i.e., recovery may be performed on individual NVlog bucketsconcurrently (i.e., without locking synchronization requirements betweenthe buckets).

The volume layer may arrange transactions 1510 associated with eachbucket into is groups 1515 a,b of transactions organized by indivisibleclass of operations such as, e.g., a dense tree merge operation (notshown), a delete operation 1520 a,c, an insert operation 1520 b,d,e, f,and a recovery operation (not shown). Each class of operation may beassociated with a finite state machine (FSM) 1530 a-d to process thetransactions for that class and ensure atomicity. Illustratively, FSMprocessing of transactions for each operation generates log entries tothe associated NVlog bucket. Effectively each FSM may act as a storageoperation state machine that stores results of the transactions whileconsuming log entries (i.e., resources of the NVlogs) of the associatedNVlog bucket. Results of a transaction may include an NVlog bucket entrystored to SSD (e.g., an insert transaction) or an object stored to SSD(e.g., a merge of level 0 to level 1 of the dense tree). Illustratively,a terminal state of the FSM processing a transaction is storage to SSDof the results of that transaction, so that NVlog bucket entriesconsumed by the FSM during processing of the transaction may bereclaimed.

A group 1515 b of one or more transactions 1520 d,e may be associatedatomically (e.g., insertion of volume data entries 610 included in ametadata page 720) with an FSM 1530. That is, transactions 1520 d,ehaving a same class of operation (e.g., insert) may be grouped accordingto metadata pages 720 which are stored to SSD. Accordingly, each group1515 b of entries 1520 d,e or single entries 1520 a,c may be tracked bya different FSM 1530 a-d. That is, an FSM may track (i.e., manage) statetransitions for a group of entries until that group is persisted on-disk(i.e., terminal state of the FSM for the group of transactions ortransaction). Each group (or single transaction) may be illustrativelyidentified by a token identifier (ID) that also identifies theassociated FSM. Notably, an NVlog bucket 1540 a may be associated withmultiple FSMs 1530 a,b, each processing a different class of operation.Accordingly, the NVlog bucket may include entries from multipledifferent active (i.e., outstanding transactions) FSMs.

In an embodiment, quota pools 1550a-d are employed to provide logicalpools of log space in NVRAM (i.e., NVlog bucket resources) for an FSM.When started, an FSM may be allocated a quota pool of sufficient size tosupport a number of log entries expected for the class of operationassociated with that FSM. Illustratively, if the pool is not available,the FSM is queued, e.g., to avoid deadlock, until such a pool (orresource) is available. The quota pool may be allocated based on amaximum calculated size for the class of operation (e.g., a merge ofdense tree level 0 with level 1, each with predetermined sizes). As logentries are processed by the FSMs, a high watermark (e.g., 70%) for thequota pools is used to forcefully close (or terminate) certain FSMs thathave a total size of entries in the quota pool exceeding the highwatermark, which would otherwise prevent reclamation of log space (i.e.,log entries). Further, in-memory shadow data structures (not shown) maybe also employed to manage outstanding token IDs (i.e., entriesin-process by the FSMs), as well as to manage log space reclamation by,e.g., queuing log entries that have not yet been reclaimed.Illustatively, the log space is managed as two portions: a first portionrecording (logging) entries, and a second portion having log entriesbeing reclaimed such that log space occupied by those reclaimed entriesmay be re-used in the first portion.

NVLog Bucket

FIG. 16 is a block diagram of the volume layer log format of the storageI/O stack. As noted, each NVlog bucket 1600 is embodied as a circularlog with allocation and reclamation pointers tracked in each log entryof the bucket. The bucket is organized to include a bucket header 1610with information about the bucket, such as a size 1615, magic number1612, a version number 1613 identifying the header format, and an errorcorrection code 1616, e.g., a cyclic redundancy check (CRC), which maybe used for error handling during replay to ensure that a correct bucketis provided to the volume layer. The NVlog bucket header 1610 isfollowed by one or more NVlog bucket log entries (log entries) 1620 andan NVlog footer 1618 which includes a magic number 1619 (the same ordifferent from magic number 1612).

Log Entry

In an embodiment, each volume log entry 1620 includes a header 1630, atoken ID 1640, a payload 1650 and footer. The header includes, interalia, a current sequence number 1635 of the entry (i.e., NVlog entrysequence number) which is 64-byte increasing up counter, and a sequencenumber of the previous log entry 1636 that is active, e.g., for replay(i.e., a reclamation pointer sequence number or last valid NVlogsequence number). For instance, a current log entry having an entrysequence number of 1000 may also include a field that stores a sequencenumber (e.g., 900) of the previous log entry that will be replayed(i.e., that is active). Use of the previous log entry sequence numberenables location of the reclamation pointer from a particular log entry,i.e., jumping to that log entry (900) during replay.

In addition, the header includes a current entry offset 1633 (e.g.,relative to a start of the NVlog in NVRAM) of the log entry 1620 withinthe NVlog bucket (i.e., NVlog offset) as well as an offset of theprevious log entry 1634 (i.e., last valid log entry NVlog offset),wherein the latter previous log entry offset is a reclamation pointeroffset used during replay to directly locate the reclamation pointer. Amagic number 1631 at the beginning of the log entries is used toeffectively delimit log entries in the event of catastrophic failureswhere a first log entry results from a partial DMA at the beginning ofthe NVlog bucket.

Illustratively, the footer of the log entry includes an error correctioncode 1660 (e.g., CRC) for the entry, which may be used to determinepartial DMA write requests and safely discard them, while the payload1650 and token ID 1640(e.g., a common payload) of the log entrydescribes the actual log entry. In an embodiment, the payload 1650includes the type or operational code (op code) of FSM, the type of logentry (EOS log, OV/NV log, etc.), and the metadata pages being logged.The token ID is illustratively used to identify the FSM associated withthe entry and to track active (i.e., outstanding) FSMs in the volumelayer, as described. Note that multiple log entries may include a sametoken ID, which denotes that those log entries are associated with thesame FSM.

In an embodiment, the entry sequence number 1635 logs the actualtransaction 1520, while the token ID groups related transactions (orsingle transaction) by FSM. Note that each FSM operates for apredetermined number of transactions (i.e., transactions within thegroup). Upon a failure/crash and during recovery, only activetransactions (and associated FSMs) at the time of the crash arereplayed. Note that the token IDs may also be used for recovery andreclamation of log entries. During reclamation, the active token IDs areused to identify active log entries (i.e., outstanding entries havingactive FSMs) in the NVlog. As such, there may be a case where a token IDhas been closed (the associated FSM has terminated), but thecorresponding log entries cannot be reclaimed because they are blockedby another token ID (having an associated active FSM) ahead of them inthe circular log. Illustratively, these blocked log entries may bequeued (in a separate queue, not shown) until the blocking token ID isclosed (i.e., the token ID is assigned a sentinel value indicating thatthe associated FSM has terminated). At that time, shadow data structures(that represent the state of the circular log in NVRAM) may be used toreclaim the queued log entries in steady-state. That is, the shadow datastructures may be used to avoid reclamation deadlock. Notably, theshadow data structures may include a “last forced entry reclaimedsequence number” (not shown), which indicates the sequence number (entrysequence number 1635) of a last log entry reclaimed when the highwatermark is exceeded. Reclamation of log entries may be monitored bytracking the reclamation pointer relative to the last forced entryreclaimed sequence number so as to manage allocation of quota pools,e.g., faster reclamation of log entries leading to greater log spacethat permits allocation of larger quota pools, whereas slowerreclamation of log entries leading to smaller log space entailsallocation of smaller quota pools.

FSM

As noted, a collection of log entries may be identified by the token IDassociated with an FSM. Illustratively, the volume layer includes aplurality of FSMs that guarantee atomicity. Each FSM may be instantiatedfor a group of transactions organized to perform an indivisibleoperation such as, e.g., a dense tree merge operation, a recoveryoperation, an append buffer flush or delete operation, the latter ofwhich may be inserted into an NVlog. Illustratively, each FSM of thevolume layer is started by logging an entry having a token start value(a first token ID sentinel value) to the NVlog bucket with a new tokenID associated with the started FSM. As the FSM progresses, more entriesfrom processing the transaction are logged to the NVRAM and are taggedwith the new token ID. Once the FSM completes, an entry is added to theNVlog bucket having a token end value (a second token ID sentinelvalue). At this point, the FSM is atomically committed to the NVRAM.Note that because the NVlog bucket may be implemented as a circular log,a terminated (i.e., closed) FSM transaction may be blocked fromreclaiming its generated log entries by another active (i.e., open) FSMalso reclaiming log entries. However, log entries generated by aterminated FSM may be safely discarded during replay because thoseentries may be discovered as closed (i.e., having token end identifiers)when the circular log is scanned during recovery.

In an embodiment, each FSM may have a different life cycle, e.g., someFSMs have shorter (and quicker) durations than others. Reclamation maythus be blocked, thereby rendering the log full. Reclamation blockingmay be detected and corrected by, e.g., monitoring the quota pool and,once the pool is consumed up to a defined threshold (70%), closing anypending FSMs that have not yet completed. For example, if an FSMrequires a number of operations to finish, but consumption of the NVlogbucket has exceeded the threshold because the FSM blocks reclamation,that FSM may be prematurely terminated (before completion of theoperations) to enable reclamation of the NVlog bucket. In an embodiment,a dynamic deadlock detection process monitors each FSM and terminatesany FSM exceeding the log size threshold. This, in turn, permitsreclamation of (i.e., frees) the log space for subsequent transactions.Illustratively, during termination of an FSM (“flush state”), new FSMsare queued. A low watermark (e.g., 50% log quota pool space) may beemployed, such that once the low watermark is reached, a new FSM mayinitiate execution.

In an embodiment, a sliding watermark window (50-70% log quota poolspace) is used for flushing FSMs such that when a high point (e.g., 70%)of the sliding watermark window (not shown) is exceeded, one or morepending FSMs may be flushed. Once reclamation reduces the used log spacebelow a low point (e.g., 50%) of the sliding watermark window, morepending FSMs may be flushed. In this manner, log space may be graduallyreclaimed and re-allocated to quota pools, such that an amount of logspace is usually available for allocation to quota pools, e.g., anamount of log space above the high point of the sliding watermark window(100%−70%=30%). Accordingly, accumulation of unprocessed FSMs is avoidedas some FSMs are usually being processed.

Quota Pool

In an embodiment, there are eight(8) UP services and eight (8)corresponding NVlog buckets, wherein each bucket is organized as acircular log allocated from physical NVRAM space. To avoid reclamationblocking as previously described, the circular logs may be abstractedusing a quota mechanism that allocates essentially a logical pool ofNVRAM space that guarantees an amount (i.e., a reservation) of logstorage space. As such, clients (e.g., the volume layer) need not beaware of the wrapping of the circular log. When a FSM starts, a quotapool of logical space sufficient for running the FSM (i.e., an expectedamount of log space) is allocated to the FSM. If the quota pool isavailable, the FSM starts. If the quota pool is unavailable, the FSM isqueued (and not started), e.g., to avoid a deadlock situation where anFSM starts but cannot finish due to insufficient resources.Specifically, when a FSM (merge FSM, delete FSM, insert FSM) starts, aquota pool of sufficient size is requested to support the collection oflog entries expected to be generated by the FSM. Only if the entirerequested quota pool is available will the FSM start; otherwise the FSMis queued until sufficient resources (quota pool) are available. Thus,instantiation of a FSM is dependent upon a sufficient resourceallocation from the NVRAM space of a quota pool which, from theperspective of the FSM, is a contiguous log.

In an embodiment, the quota pool is allocated statically to a FSM, i.e.,a reservation of an amount of log space requested for a quota pool. Foreach type of FSM (e.g., merge, delete, insert), a precise amount of logspace (bytes) required by the FSM may be calculated or known a priori.For example, an amount of log space required (i.e., generated output) bya merge FSM (i.e., a merge of one or more levels of the dense tree) isknown to be at most a number of entries of a lowest level of the merge(i.e., the output result of the merger of the levels) along with a tokenstart and token end. Accordingly, a static allocation quota may beprovided for each class of FSM. Note that the number of FSM generatedlog entries may vary widely according to the class of FSM (e.g., 3 logentries for a simple insert FSM to many entries for a merge FSM thatmerges lower levels of the dense tree). Illustratively, when a FSM makesa request for a log (token start), a mapping table is examined todetermine the class of FSM and the amount of expected log space (e.g.,maximum amount of log space) required by that class of FSM. Adetermination is then made as to whether a quota pool having the amountof log space is available. If so, the FSM is started and, if not, theFSM is queued.

In an embodiment, allocation of quota is based on a worst case, i.e.,maximum log space expected to be needed (i.e., generated log entries) bythe FSM. Although the log buckets may be configured to avoid gettingfull (e.g., based on a rate of incoming I/O write requests), some FSMsmay run longer than other FSMs, such that the long running FSMs mayblock reclamation, as previously noted. Concurrency control may beimplemented for merge FSMs and delete FSMs, such that a number ofoutstanding merge and delete operations are limited (thus limiting acorresponding number of generated log entries). In addition, a ceiling(cap) may be provided for a number of outstanding PUTs. Illustratively,the logs may be sized to accommodate all of the FSMs for theseoutstanding operations (e.g., insert, delete, merge). If a particularFSMs is too slow, more CPU resources may be allocated to clear the log(i.e., increase processing by the FSM, so that log entries may bereclaimed); alternatively the FSM may be terminated.

Crash Recovery

Illustratively, when a node crashes, each layer of the I/O storage stackperforms crash recovery. During crash recovery, the volume layerinitiates a replay process by performing DMA read operations from NVRAMto memory so that the NVlog buckets are loaded into memory. Since thenumber of log buckets is the same as the number of UP services, thereplay process may execute in parallel across the UP services (i.e.,each UP service replays a different NVlog bucket). Broadly stated, theNVlog bucket is traversed (i.e., scanned) to identify a highest sequencenumber log entry indicating a last (i.e., latest) log entry from which anumber of previous valid (active) log entries may be determined.Illustratively, log entries are in ascending time order; accordingly logentries may be traversed from oldest sequence number to newest sequencenumber while noting the token IDs (i.e., token ID field 1640) of eachtraversed entry to determine active FSMs at the time of the crash. Theactive FSMs may be added to the shadow data structures for replaypurposes. Note that those log entries having closed token IDs (i.e., thesentinel value indicating terminated FSMs) are removed from the shadowstructures thereby leaving only active, pending FSMs for replay.

After populating the shadow structures, the replay process may choose torollback/roll forward the various FSMs based on a context of the FSM atthe time of the crash. Classes of logs, i.e., old value (OV)/new value(NV) logs, are illustratively used to implement roll-forward/roll-backsemantics. OV/NV logs copy old content of metadata or new content ofmetadata into the NVRAM. Based on context during recovery, either theold copy or the new copy may be used. Note that this is a generalpurpose log entry technique that enables roll-back or roll-forwardduring recovery (based on bytes of data wrapped around a log entry). Forexample, if an extent (e.g., a metadata page) is to be updated from 1 to2, the values 1 and 2 are copied to the OV/NV logs and the type ofextent is recorded, as well as the key (i.e., old copy=1, new copy=2).Based on context of the FSM, the extent may be fixed with either 1 or 2during recovery (i.e., by the replay process). Assume now that themetadata page is 64 KB in length and 8 bytes are updated at the end ofthe page, the old copy=1, the new copy=2. Both OV/NV copies aremaintained in NVRAM and, based on the FSM that aborted/crashed, recoverymay involve rolling-forward or rolling-back. Illustratively, theappropriate information is then applied during recovery. Note thatroll-forward includes the new copy of the metadata. At the end ofreplay, each UP service may destroy its serviced log bucket and declarethat the replay is complete for that log bucket. Note also that duringreplay of FSMs, no new (fresh) log quotas need be allocated; thereplayed FSMs simply use their respective prior quotas.

For example, the FSM may be associated with the delete operationinserted into the NVlog, and another FSM may be associated withprocessing of the circular log. The insert operation is illustrativelyidempotent such that, if a crash occurs during the next insertoperation, the operation may be rolled back and restarted. Note that thedelete is a roll-forward operation such that during crash recovery, theon-disk data structures are fixed to indicate how far the FSM hasprogressed and recovery can proceed from that point. That is, crashrecovery may be attempted in the event of a failure wherein a context isprovided to determine whether to roll-forward or roll-back. Toroll-back, the FSM must be restarted; to roll-forward exactly oncesemantics (EOS) may be used to ensure any deletions are idempotent(i.e., if deletes have occurred, then roll-forward may be performed).

During replay a first step is to patch up (resolve) the OV/NV logson-disk and/or in NVRAM as noted. Thereafter, the second step is toprocess those log entries that require roll-forward or roll-back. Atleast two passes through the NVlog bucket are required to (1) recovertoken IDs, i.e., determine which IDs (i.e., associated FSMs) are active,and (2) process the active token IDs (log entries) by highest sequencenumber, proceeding backwards from oldest to newest sequence number.Illustratively, log entries that are active are identified using thehighest sequence number of log entry in accordance with the first passthrough the NVlog bucket. The second pass traverses the log entries fromoldest to newest (using the sequence numbers). Note that identificationof the highest sequence number can be used to determine the oldestsequence number. In addition, the walk (i.e., traversal) from thebeginning of the NV log bucket to the end of the bucket involvescrawling (searching) for the highest sequence number. Illustratively,upon finding a sequence number that is lower than a last previoussequence number, the traversal is stopped and the previous highestsequence number (log entry) is parsed to determine a set of log entriesthat need to be replayed.

More specifically, the bucket header/footer 1610/1618 may be firstinspected for consistency during the replay process, wherein suchinspection includes checking the magic number 1612, size 1615, and errorcorrection code 1616. Replay logic of the volume layer may then enter ascanning phase to scan the bucket for log entries from the beginning upto the highest current sequence number. The replay logic may validatethe magic number and error correction code for each log entry. If theerror correction code does not match, those log entries may be discardedas partial DMA operations and the scanning stops. Because each log entrymaintains its size (e.g., entry size 1637), a next log entry may beefficiently traversed as long as the current log entry sequence numberis one less than the next log entry. Illustratively, once the highestlog entry sequence number is discovered, the reclamation pointer offsetto the reclamation pointer is maintained in the log bucket. In the eventthat the first log entry in the bucket is discovered to be a partialDMA, scanning logic “crawls”, e.g., 8 bytes at a time, to discover thenext valid log entry based on the magic number of the entry. It shouldbe noted that due to the nature of the circular log and the fact thateach log entry is a variable size, the offset at which a wraparoundoccurs may lead to invalid entries from a previous loop/generation atthe bottom of the log bucket. However these log entries may be safelyignored because those log entries have either incorrect error correctioncodes due to overwrites or their sequence numbers may be lower than themaximum identified sequence number.

Once the scanning phase completes and identifies any allocation andreclamation pointers in the log bucket, the shadow structures areprepared to organize the active FSMs. Illustratively, these shadowstructures are populated during traversal of the log bucket between thereclamation and allocation pointers. Note that log entries having tokenIDs determined to be already closed (e.g., having the sentinel token ID)may be safely discarded because the associated FSMs are alreadycomplete. Similarly, if a partial DMA operation is encountered (e.g.,because the error correction code does not match), all subsequent logentries from that point to the allocation pointer may be safelydiscarded because they represent partial DMA operations.

Advantageously, the technique described herein enables efficientorganization of log entries into a class of FSM, wherein the FSM has acontext with respect to roll-forward or roll-back. Transactions areorganized and classified by operation type and bound to an executionengine (FSM). Depending on the state of the FSM at the time of a crash,recovery may perform in accordance with roll-back or roll-forward. Inaddition, the quota pool assigned/allocated to a FSM depends upon thetype of operation and transactions. That is, allocations are made to theNVlog bucket based on the type of operation and the size of buffers forthat operation. Recovery is performed based on the state of the FSMexecuting the type of operation at the time of the crash to determinewhether recovery involves rolling-back to old (previous) metadata orrolling-forward to new (current) metadata associated with the operation.

In sum, the embodiments herein describe two aspects to logging:steady-state logging and recovery. For steady-state logging, the logs(NVlog bucket and log entries) are organized per UP service tofacilitate (exploit) concurrency and have a physical layout/format usingsequence numbers (in a header) and error correction code (in a footer)as well descriptions of the log entry (in a common payload) thatincludes a token ID to identify the type of FSM and the type of logentry. Illustratively, the log bucket resource is prevented from beingover run through the use of quota pools, wherein a watermark for thequota pool is used to forcefully close certain FSMs that are longrunning and that prevent reclamation. In-memory shadow structures may beemployed to manage any outstanding token IDs (FSM) as well as managespace reclamation by queueing those log entries that have not yet beenreclaimed. Additionally, concurrency control and log size/bucket sizeare provided to ensure sufficient storage/log space for expectedactivities.

For crash recovery, two passes may be performed through the NV logbucket. Illustratively, the first pass is performed to find the activelog entries and the second pass eliminates any FSMs that havecompleted/finished, leaving only active FSMs. Roll-forward or roll-backsemantics may be then employed using OV/NV logs to replay the logs andrepair the on-disk file system data structures.

The foregoing description has been directed to specific embodiments. Itwill be apparent, however, that other variations and modifications maybe made to the described embodiments, with the attainment of some or allof their advantages. For instance, it is expressly contemplated that thecomponents and/or elements described herein can be implemented assoftware encoded on a tangible (non-transitory) computer-readable medium(e.g., disks and/or CDs) having program instructions executing on acomputer, hardware, firmware, or a combination thereof. Accordingly thisdescription is to be taken only by way of example and not to otherwiselimit the scope of the embodiments herein. Therefore, it is the objectof the appended claims to cover all such variations and modifications ascome within the true spirit and scope of the embodiments herein.

What is claimed is:
 1. A method comprising: receiving at a storagesystem an input/output (I/O) request, wherein the storage systemincludes a persistent memory coupled to central processor (CPU) and oneor more storage devices; associating a first transaction with the I/Orequest; allocating a circular log from the persistent memory to a firstfinite state machine (FSM) for processing the first transaction, thefirst FSM associated with a first token identifier (ID); logging a startentry in the circular log; in response to processing the firsttransaction, recording one or more entries to the circular log, eachrecorded entry including a sequence number and a token ID field; inresponse to a crash of the storage system, scanning the recorded entriesof the circular log to determine whether the first FSM is active at atime of the crash; and in response to determining that the first FSM isactive at the time of the crash, replaying the recorded entries of thecircular log having the first token ID as a value of the token ID field.2. The method of claim 1 wherein scanning the recorded entries furthercomprises: discarding the recorded entries failing a checksum.
 3. Themethod of claim 1 wherein scanning the recorded entries furthercomprises: adding the first FSM and a second FSM to a shadow structure,the second FSM associated with a sentinel value indicating that thesecond FSM is closed; and removing each recorded entry having thesentinel value as a value of the token ID field.
 4. The method of claim1 wherein scanning the recorded entries further comprises: making afirst pass through the recorded entries to identify the first FSM asactive; and making a second pass through the recorded entries todetermine a highest sequence number of the recorded entries.
 5. Themethod of claim 4 wherein making the second pass through the recordedentries further comprises: determining whether a current sequence numberof a respective entry of the recorded entries is lower than a previoussequence number of a prior respective entry; and in response todetermining that the current sequence number of the respective entry ofthe recorded entries is lower than the previous sequence number of theprior respective entry, assigning the previous sequence number as thehighest sequence number.
 6. The method of claim 2 wherein discarding therecorded entries failing a checksum further comprises: scanning thecircular log to identify a magic number so as to determine a nextrecorded entry, wherein each recorded entry includes the magic s number.7. The method of claim 1 wherein the persistent memory is one of anon-volatile random access memory and a solid state drive.
 8. The methodof claim 1 wherein replaying the recorded entries of the circular logfurther comprises: applying one of an old value log and a new value logto each replay entry of the circular log.
 9. The method of claim 8wherein applying the old value log further comprises: restarting thefirst FSM.
 10. The method of claim 8 wherein applying the new value logfurther comprises: applying the new value log to a first replay entry ofthe circular log; and ensuring that replay of first replay entry isidempotent.
 11. A system comprising: a storage array having one or morestorage devices; and a node having a central processor (CPU) connectedto a memory, a persistent memory and the storage array, the CPUconfigured to execute one or more processes stored in the memory, theone or more processes when executed operable: receive at a storagesystem an input/output (I/O) request; associate a first transaction withthe I/O request; allocate a circular log from the persistent memory to afirst finite state machine (FSM) for processing the first transaction,the first FSM associated with a first token identifier (ID); log a startentry in the circular log; in response to processing the firsttransaction, record one or more entries to the circular log, eachrecorded entry including a sequence number and a token ID field; inresponse to a crash of the storage system, scan the recorded entries ofthe circular log to determine whether the first FSM is active at a timeof the crash; and in response to determining that the first FSM isactive at the time of the crash, replay the recorded entries of thecircular log having the first token ID as a value of the token ID field.12. The system of the claim 11 wherein the one or more processes whenexecuted to scan the recorded entries is further operable to: discardthe recorded entries failing a checksum.
 13. The system of claim 11wherein the one or more processes when executed to scan the recordedentries is further operable to: add the first FSM and a second FSM to ashadow structure, the second FSM associated with a sentinel valueindicating that the second FSM is closed; and remove each recorded entryhaving the sentinel value as a value of the token ID field.
 14. Thesystem of claim 11 wherein the one or more processes when executed toscan the recorded entries is further operable to: make a first passthrough the recorded entries to identify the first FSM as active; andmake a second pass through the recorded entries to determine a highestsequence number of the recorded entries.
 15. The system of claim 14wherein the one or more processes when executed to make the second passthrough the recorded entries is further operable to: determine whether acurrent sequence number of a respective entry of the recorded entries islower than a previous sequence number of a prior respective entry; andin response to determining that the current sequence number of therespective entry of the recorded entries is lower than the previoussequence number of the prior respective entry, assign the previoussequence number as the highest sequence number.
 16. The system of claim12 wherein the one or more processes when executed to discard therecorded entries failing a checksum is further operable to: scan thecircular log to identify a magic number so as to determine a nextrecorded entry, wherein each recorded entry includes the magic number.17. The system of claim 11 wherein the persistent memory is one of anon-volatile random access memory and a solid state drive.
 18. Thesystem of claim 11 wherein the one or more processes when executed toreplay the recorded entries of the circular log is further operable to:apply one of an old value log and a new value log to each replay entryof the circular log.
 19. The system of claim 18 wherein the one or moreprocess when executed to apply the new value log is further operable to:apply the new value log to a first replay entry of the circular log; andensure that replay of first replay entry is idempotent.
 20. Anon-transitory computer readable medium including program instructionsfor execution on one or more processors, the program instructions whenexecuted operable to: implement a storage input/output (I/O) stack thatoperates with a persistent memory coupled to the one or more processorsand with one or more solid state drives (SSDs); receive an I/O request;associate a transaction with the I/O request; allocate a circular logfrom the persistent memory to a first finite state machine (FSM) forprocessing the first transaction, the first FSM associated with a firsttoken identifier (ID); log a start entry in the circular log; inresponse to processing the transaction, record one or more entries tothe circular log, each recorded entry including a sequence number and atoken ID field; in response to a crash of the storage I/O stack, scanthe recorded entries of the circular log to determine whether the firstFSM is active at a time of the crash; and in response to determiningthat the first FSM is active at the time of the crash, replay therecorded entries of the circular log having the first token ID as avalue of the token ID field.